import type { ExamineApproveCheckParams, ExamineApproveListParams, ExamineApproveLogParams, ExamineApproveParams } from './types'
import request from '/@/utils/request'

// 获取审批列表
export function getExamineList(params: ExamineApproveListParams) {
  return request({
    url: '/api/examineApprove',
    method: 'get',
    params,
  })
}

// 获取审批详情
export function getExamineDetail(id: string) {
  return request({
    url: `/api/examineApprove/show/${id}`,
    method: 'get',
  })
}

// 获取审批人列表
export function getApprovers(id: string) {
  return request({
    url: `/api/examineApprove/approvers/${id}`,
    method: 'get',
  })
}

// 提交审批
export function createExamine(data: ExamineApproveParams) {
  return request({
    url: '/api/examineApprove',
    method: 'post',
    data,
  })
}

// 修改审核人
export function checkExamine(data: ExamineApproveCheckParams) {
  return request({
    url: `/api/examineApprove/${data.id}`,
    method: 'put',
    data,
  })
}

// 获取审核日志
export function getExamineLogList(params: ExamineApproveLogParams) {
  return request({
    url: '/api/examineApprove/logList',
    method: 'get',
    params,
  })
}

// 删除审批
export function deleteExamine(id: string) {
  return request({
    url: `/api/examineApprove/${id}`,
    method: 'delete',
  })
}

// 审核接口
export function checkExamineH5(data: ExamineApproveCheckParams & { status: string; remark: string }) {
  return request({
    url: '/api/examineApprove/check',
    method: 'post',
    data,
  })
}
